package config

type server struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
}

type mysql struct {
	server
	Database string `json:"database"`
}

type smtp struct {
	server
	Mail string `json:"mail"`
	Url  string `json:"url"`
}

type Config struct {
	ServerPort int    `json:"serverPort"`
	Mysql      mysql  `json:"mysql"`
	Smtp       smtp   `json:"smtp"`
	Realm      string `json:"realm"`
}

var instance *Config = nil

func GetConfig() *Config {
	if instance == nil {
		instance = &Config{
			ServerPort: 7777,
			Mysql: mysql{
				server: server{
					Host:     "127.0.0.1",
					Port:     3306,
					User:     "root",
					Password: "root",
				},
				Database: "auth",
			},
			Smtp: smtp{
				server: server{
					Host:     "",
					Port:     465,
					User:     "",
					Password: "",
				},
				Url: "http://localhsot:7777",
			},
			Realm: "localhost",
		}
	}
	return instance
}
